<?php
class safeController extends accessController{
    public static function _right(){
        return array(
            array('安全设置',1),
            array('修改账号','change_name,change_name_'),
            array('修改信息','change_info_'),
            array('修改密码','change_pwd,change_pwd_'),
            
        );
    }
    public function index(){
        
    }
    public function change_name(){
        $info=load_service('info');
        $data=$info->get_info();
        $user=load_service('i_user_login');
        $session=$user->user_session();
        include($this->viewer_dir.'safe/change_name.php');
    }
    public function change_name_(){
        $safe=load_service('safe');
        if($safe->check_blank1($_POST)){
            if($safe->is_correct('user_password')){
                if($safe->update_name()){
                    alert('账号修改成功！请重新登陆！');
                    jump('login','logout');
                }else{
                    alert('账号修改失败！');
                    back();
                }
            }else{
                alert('密码不正确！');
                back();
            }
        }else{
            alert('密码、新账号不能为空！');
            back();
        }
    }
    public function change_info_(){
        $info=load_service('info');
        $r=$info->update_info($_POST);
        autoalert($r);
        back();
    }
    public function change_pwd(){
        include($this->viewer_dir.'safe/change_pwd.php');
    }
    public function change_pwd_(){
        $safe=load_service('safe');
        if($safe->check_blank2($_POST)){
            if($safe->is_correct('old_password')){
                if($safe->update_pwd()){
                    alert('密码修改成功！');
                    jump('safe','change_pwd');
                }else{
                    alert('密码修改失败！');
                    back();
                }
            }else{
                alert('旧密码不正确！');
                back();
            }
        }else{
            alert('旧密码、新密码不能为空！');
            back();
        }
    }
}